home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / answrbok / 5_9.lha / 5_9 / 5_9c4.c < prev    next >
Text File  |  1993-08-08  |  570b  |  31 lines

  1. * Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
  2. * The C++ Answer Book */
  3. * Tony Hansen */
  4. * All rights reserved. */
  5. ain(int argc, char **argv)
  6.  
  7.    srand(1);            // DELETE
  8.    if (argc != 3)
  9. error("two arguments expected");
  10.  
  11.    int count = 0;
  12.    int m = atoi(argv[1]);    // number of set members
  13.    int n = atoi(argv[2]);    // in the range 1..n
  14.    intset s;
  15.    set_is(s, m, n);
  16.  
  17.    while (count < m)
  18. {
  19. int t = randint(n);
  20. if (member_is(s, t) == 0)
  21.     {
  22.     insert_is(s, t);
  23.     count++;
  24.     }
  25. }
  26.  
  27.    print_in_order(&s);
  28.    delete_is(s);
  29.    return 0;
  30.  
  31.